package common.zhudi.utils;

import org.springframework.util.DigestUtils;

import java.util.regex.Pattern;

import static common.zhudi.contant.UserContant.SALT;

public class UserUtils {

    /**
     * 获得加密密码
     * @param password
     * @return
     */
    public static String getencryptPassword(String password){
       return  DigestUtils.md5DigestAsHex((SALT + password).getBytes());
    }

    /**
     * 检查手机号是否合法
     * @param phoneNumber
     * @return
     */
    public static boolean isValidPhoneNumber(String phoneNumber) {
        if ((phoneNumber != null) && (!phoneNumber.isEmpty())) {
            return Pattern.matches("^1[3-9]\\d{9}$", phoneNumber);
        }
        return false;
    }


}
